﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MapReduce
{
    public abstract class BaseMapper<ResultKeyType, ResultValueType> where ResultKeyType : IComparable
    {
        protected Dictionary<ResultKeyType, List<ResultValueType>> result;

        public BaseMapper()
        {
            result = new Dictionary<ResultKeyType, List<ResultValueType>>();
        }

        protected void Emit(ResultKeyType key, ResultValueType value)
        {
            if (!result.ContainsKey(key))
                result.Add(key, new List<ResultValueType>());
            
            result[key].Add(value);
        }

        public abstract void Map();
    }
}
